<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title>Gwack Admin</title>
<link href="style.css" rel="stylesheet" type="text/css" />

</head>
<body>
<div id="container">
<?php include("menu.php"); ?>

<div id="content">
    <div id="leftBox">
        <div class="contentBox">
            <div class="innerContent">

<?php
$gwname = $_GET['name'] or die ("why");
$newrestore = $_GET['restoredir'];
$basepath = $_GET['basep'];
$restorepath = $_GET['restore'];

$cmd = "sudo /opt/gwack/newrestore.sh $gwname $basepath $restorepath $newrestore";

$out = shell_exec($cmd) or die("Something wrong here!");  

if ($out == 0)
{

	$configfile = '/etc/opt/gwack/gwack.xml';
	$x = simplexml_load_file($configfile);

	foreach ($x->server as $s)
	{
		if ($s->name == $gwname)
		{
			$s->restorepath = $restorepath.'/'.$newrestore;
			file_put_contents($configfile, $x->asXML()) or die("save failed");

		}
	}

         echo '<div class="successBox">';
          echo '<div class="successBoxTop">&nbsp;</div>';
          echo '<div class="msgBoxContent successIcon">';
          echo '<p>Success!';
		  echo " $gwname restore path reset to:<strong> $restorepath/$newrestore</strong></p>";
          echo '</div></div></div>';
}

else
{
	echo '<div class="errorBox"><div class="errorBoxTop">&nbsp;</div>';
    echo '<div class="msgBoxContent errorIcon">';
    echo '<p>Error. Restore failed. </p>';
    echo '</div></div></div>';
}
?>

</div></div></div></div>
</body>
</html>
<?php include 'footer.html'; ?>


